import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["className", "layout", "style", "description", "children", "title", "tip", "status", "trend", "prefix", "icon"];
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { QuestionCircleOutlined } from '@ant-design/icons';
import { Badge, ConfigProvider, Statistic as AntdStatistic, Tooltip } from 'antd-v4';
import classNames from 'classnames';
import { useContext } from 'react';
import './index.less';

var Statistic = function Statistic(props) {
  var _classNames;

  var className = props.className,
      _props$layout = props.layout,
      layout = _props$layout === void 0 ? 'inline' : _props$layout,
      _props$style = props.style,
      style = _props$style === void 0 ? {} : _props$style,
      description = props.description,
      children = props.children,
      title = props.title,
      tip = props.tip,
      status = props.status,
      trend = props.trend,
      prefix = props.prefix,
      icon = props.icon,
      others = _objectWithoutProperties(props, _excluded);

  var _useContext = useContext(ConfigProvider.ConfigContext),
      getPrefixCls = _useContext.getPrefixCls;

  var prefixCls = getPrefixCls('pro-card-statistic');
  var classString = classNames(prefixCls, className);
  var statusClass = classNames("".concat(prefixCls, "-status"));
  var iconClass = classNames("".concat(prefixCls, "-icon"));
  var wrapperClass = classNames("".concat(prefixCls, "-wrapper"));
  var contentClass = classNames("".concat(prefixCls, "-content"));
  var statisticClassName = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-layout-").concat(layout), layout), _defineProperty(_classNames, "".concat(prefixCls, "-trend-").concat(trend), trend), _classNames));

  var tipDom = tip && _jsx(Tooltip, {
    title: tip,
    children: _jsx(QuestionCircleOutlined, {
      className: "".concat(prefixCls, "-tip")
    })
  });

  var trendIconClassName = classNames("".concat(prefixCls, "-trend-icon"), _defineProperty({}, "".concat(prefixCls, "-trend-icon-").concat(trend), trend));

  var trendDom = trend && _jsx("div", {
    className: trendIconClassName
  });

  var statusDom = status && _jsx("div", {
    className: statusClass,
    children: _jsx(Badge, {
      status: status,
      text: null
    })
  });

  var iconDom = icon && _jsx("div", {
    className: iconClass,
    children: icon
  });

  return _jsxs("div", {
    className: classString,
    style: style,
    children: [iconDom, _jsxs("div", {
      className: wrapperClass,
      children: [statusDom, _jsxs("div", {
        className: contentClass,
        children: [_jsx(AntdStatistic, _objectSpread({
          title: (title || tipDom) && _jsxs(_Fragment, {
            children: [title, tipDom]
          }),
          prefix: (trendDom || prefix) && _jsxs(_Fragment, {
            children: [trendDom, prefix]
          }),
          className: statisticClassName
        }, others)), description && _jsx("div", {
          className: "".concat(prefixCls, "-description"),
          children: description
        })]
      })]
    })]
  });
};

export default Statistic;